package com.yupi.yangoj.judge.codesandbox;

import com.yupi.yangoj.judge.codesandbox.model.ExecuteCodeRequest;
import com.yupi.yangoj.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;


/**
 * 代理设计模式：代码沙箱代理对象，可以在原本代码沙箱实例上添加增强方法，比如在执行方法前后打印日志
 */
@Data
@AllArgsConstructor
@Slf4j
public class CodeSandBoxProxy implements CodeSandBox{

    private final CodeSandBox codeSandBox;

    /**
     * 执行方法前后打印日志
     * @param executeCodeRequest
     * @return
     */
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱请求参数：" + executeCodeRequest.toString());
        ExecuteCodeResponse executeCodeResponse = codeSandBox.executeCode(executeCodeRequest);
        //log.info("代码沙箱响应结果" + executeCodeResponse.toString());
        return executeCodeResponse;
    }



}
